package com.yi.apidriver.service;

import com.yi.apidriver.remote.ServiceDriverUserClient;
import com.yi.apidriver.remote.ServiceMapClient;
import com.yi.internalcommon.dto.Car;
import com.yi.internalcommon.dto.ResponseResult;
import com.yi.internalcommon.request.ApiDriverPointRequest;
import com.yi.internalcommon.request.PointRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class PointService {
    @Autowired
    private ServiceDriverUserClient serviceDriverUserClient;
    @Autowired
    private ServiceMapClient serviceMapClient;

    public ResponseResult upload(ApiDriverPointRequest apiDriverPointRequest){
        //获取carId
        Long carId = apiDriverPointRequest.getCarId();
        //通过carId 获取tid,trid 调用service-driver-user接口
        ResponseResult<Car> carById = serviceDriverUserClient.getCarById(carId);
        Car data = carById.getData();
        String tid = data.getTid();
        String trid = data.getTrid();
        //调用地图上传
        PointRequest pointRequest = new PointRequest();
        pointRequest.setTid(tid);
        pointRequest.setTrid(trid);
        pointRequest.setPoints(apiDriverPointRequest.getPoints());
        return serviceMapClient.upload(pointRequest);
    }
}
